CS 157 : Assignment 2 Douglas R . Lanman

نویسنده

  • Douglas R. Lanman
چکیده

The union-find data structure, utilizing the “union-by-rank” and “path compression” heuristics, is one of the most efficient disjoint-set data structures known [1]. In general, union-find can be applied to any problem in which one must determine membership within a set. For instance, in class we studied its application within Kruskal’s algorithm, where it was used to efficiently detect connected component of a graph. In general, union-find supports three primary operations: insertion, union, and find. As discussed by Kaplan et al., in many applications it is also desirable to support deletion [3]. In this write-up we present “lazy-deletion”: a straightforward modification of the classic unionfind data structure which will allow deletions. In particular, lazy deletion will not alter the asymptotic worst-case running times of either the union or find procedures. Recall that the union-find data structure maintains a number of rooted trees. If a node has no children, then we can delete it without incident (i.e., free any memory or other resources associated with it). If a node has children then we cannot eliminate it immediately – otherwise its children would become isolated from the root node. As a result, we adopt the “lazy deletion” policy, in which nodes with children are marked for deletion and, as their children are removed over time, eventually deleted. This write-up is organized into four sections. In Section 1 we will discuss the basic modifications that must be made to Make-Set and Union to implement lazy deletion. In Section 2, the pseudocode for insertion and deletion will be presented. In Section 3, the necessary modifications for Find-Set will be presented. Finally, in Section 4, the relative merits of lazy deletion will be discussed in the context of alternate implementations.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

CS 157 : Assignment 6 Douglas R . Lanman 8 May 2006 Problem 1 : Evaluating Convex Polygons

Problem 1: Evaluating Convex Polygons This write-up presents several simple algorithms for determining whether a given set of twodimensional points defines a convex polygon (i.e., a convex hull). In Section 1.1, we introduce the notion of regular polygons and provide examples of both convex and non-convex point sets. Section 1.2 presents an algorithm for ordering a set of points such that a cou...

متن کامل

CS 157 : Assignment 4 Douglas

This write-up presents the design and analysis of several algorithms for determining the maximum sum of certain subsets of one-dimensional arrays. In the first section, we consider the Maximum Subsequence Sum (MSS) problem: given an array A with signed integer elements, find a contiguous subarray with the maximum possible sum. In Section 2, we extend our algorithm to handle the case of cyclic s...

متن کامل

CS 157 : Assignment 3

In this write-up, we extend quicksort to the task of fuzzy sorting of intervals. In many situations the precise value of a quantity is uncertain (e.g., any physical measurement is subject to noise). For such situations we may represent a measurement i as a closed interval [ai, bi], where ai ≤ bi. A fuzzysort is defined as a permutation 〈i1, i2, . . . , in〉 of the intervals such that there exist...

متن کامل

CS 195 - 5 : Machine Learning Problem Set 1

Show that the prediction errors y − f (x; ˆ w) are necessarily uncorrelated with any linear function of the training inputs. That is, show that for any a ∈ R d+1ˆσ(e, a T x) = 0, where e i = y i − ˆ w T x i is the prediction error for the i th training example.

متن کامل

EN 292s34 / CS 220: 3D Photography and Geometry Processing Assignment 2: 3D Photography using Planar Shadows

The goal of this assignment is to build an inexpensive, yet accurate, 3D scanner using household items and a camera. Specifically, we’ll implement the “desktop scanner” originally proposed by Jean-Yves Bouguet and Pietro Perona [3]. As shown in Figure 1, our instantiation of this system is composed of five primary items: a camera, a point-like light source, a stick, two planar surfaces, and a c...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2006